import React from 'react';
import {Provider} from "react-redux"; // 引入Provider组件
import { store, persistStores } from './store/index';
import './App.css';
import './style/common.scss'
import './style/animate.scss'
import Promote from './views/Promote/promote'
import Index from './views/index/index'
import Top from "./views/Top/top";
import LyricsPage from "./views/lyrics";
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link,
  Redirect
} from "react-router-dom";
import 'element-theme-default';
import { loadStyle } from "./util/utils";
import { iconfontUrl, iconfontVersion } from "./assets";
import {PersistGate} from 'redux-persist/lib/integration/react';


iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele));
})


class App extends React.Component{

  render() {
    const router = [
    ];
    const { pathname } = location;
    return (
        <Provider store={store}>
          <PersistGate loading={null} persistor={persistStores}>
            {
              pathname.indexOf('/lyrics') >= 0?
                  <Router>
                    <Route exact path="/lyrics/:id">
                      <LyricsPage />
                    </Route>
                  </Router>
                  :
                  <Router>
                    <Top isScreen={false} />
                    <Route path="/" component={Index}/>
                  </Router>
            }
          </PersistGate>
        </Provider>
    )
  }
}


export default App;
